package com.dq.Week3.day12.list;

import java.io.FileNotFoundException;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * 使用 ArtShowService接口实现一些功能
 */
public class ArtShowDemo {

    public static void main(String[] args) throws FileNotFoundException {


        ArtShowService artShowService = new ArtShowServiceImpl();

        while (true){
            System.out.println("1. 展示全部 2.添加才艺 3.才艺通过 4.未表演名单 5.退出");
            Scanner scanner = new Scanner(System.in);
            String s = scanner.next();

            switch (s){

                case "1":
                    List<ArtShow> all = artShowService.getAll();
                    all.forEach(e-> System.out.println(e));
                    break;
                case "2":
                    System.out.println("请输入学生的名字");
                    String name = scanner.next();
                   if (isNotStu(name))
                   {
                       artShowService.addArtShow(name);
                       System.out.println("添加成功");
                   }else{
                       System.out.println("添加失败");
                   }
                    break;
                case "3":
                    System.out.println("请输入学生的名字");
                    String name1 = scanner.next();
                    System.out.println("输入学生的才艺");
                    String art = scanner.next();
                    System.out.println("输入学生的表演状态");
                    int state = scanner.nextInt();
                    System.out.println("输入学生的表演次数");
                    int count = scanner.nextInt();
                    ArtShow artShow = new ArtShow(name1, art, state, count);
                    artShowService.updateArtShow(artShow);

                    break;
                case "4":
                    List<String> noShowNames = artShowService.getNoShowNames();
                    System.out.println(noShowNames);
                    break;
                case "5":
                    System.out.println("886");
                    return;
                default:
                    System.out.println("输入错误");

            }

        }

    }
    //123
//    public static boolean isStu(String name) throws FileNotFoundException {
//        List<ArtShow> list = ArtShowUtils.creatList();
//        for (ArtShow a : list) {
//            if (a.getStuName().equals(name))
//            {
//                return true;
//            }
//        }
//        return false;
//    }
    public static boolean isNotStu(String name) throws FileNotFoundException {
        List<ArtShow> list = ArtShowUtils.creatList();
        for (ArtShow a : list) {
            if (a.getStuName().equals(name))
            {
                return false;
            }
        }
        return true;
    }

}
